﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;
using System.IO;
using DevComponents.DotNetBar;
using carinfor;
using System.Net;
using Newtonsoft.Json;
using System.Diagnostics;

namespace 系统设置
{
    public partial class setting : Form
    {
        carinfor.configIni configini = new carinfor.configIni();
        private string diwmp;
        private string cgjlx;
        private string pef;
        private bool isAdmin = false;
        public setting()
        {
            String[] CmdArgs = System.Environment.GetCommandLineArgs();
            if (CmdArgs.Length > 1)
            {
                if (CmdArgs[1] == "admin")
                    isAdmin = true;
                //isautostart = true;
            }
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //this.TitleText+= Exhaust.version.versionNumber;
            //GetVersion();
            initConfigInfo();
            initSelfData();
            tabPage2.Parent = null;
            tabPage3.Parent = null;
            tabPage4.Parent = null;
            tabPage5.Parent = null;
            tabPage6.Parent = null;
            //tabControl1.TabPages[1].Hide();
            //tabControl1.TabPages[2].Hide();
            //tabControl1.TabPages[3].Hide();
            //tabControl1.TabPages[4].Hide();
            //tabControl1.TabPages[5].Hide();

        }
        private string version = "";
        private void GetVersion()
        {
            //version = System.Configuration.ConfigurationManager.AppSettings["Version"].ToString();
            labelVersion.Text = "Version:V" + version;
        }
        string updateUrl = "";
        private void initConfigInfo()
        {
            carinfor.equipmentConfigInfdata equipconfig = configini.getEquipConfigIni();
            updateUrl = equipconfig.updateUrl;
            carinfor.VmasConfigInfdata vmasconfig = configini.getVmasConfigIni();
            carinfor.AsmConfigInfdata asmconfig = configini.getAsmConfigIni();
            carinfor.SdsConfigInfdata sdsconfig = configini.getSdsConfigIni();
            carinfor.BtgConfigInfdata btgconfig = configini.getBtgConfigIni();
            carinfor.DynConfigInfdata dynconfig = configini.getDynConfigIni();
            carinfor.LugdownConfigInfdata lugdownconfig = configini.getLugdownConfigIni();
            carinfor.RotateConfigData rotateconfig = configini.getRotateConfigIni();
            StringBuilder temp = new StringBuilder();
            temp.Length = 2048;
            try
            {
                
                ini.INIIO.GetPrivateProfileString("废气仪标定", "PEF", "907", temp, 2048, @"D:\环检配置文件\废气分析仪.ini");          //读配置文件（段名，字段，默认值，保存的strbuilder，大小，路径）
                pef = temp.ToString();
                textBoxPEF.Text = pef;
            }
            catch
            { }
            comboBoxHJT.Text = equipconfig.TestStandard;
            textBoxVmasNdz.Text = vmasconfig.Ndz.ToString("0.0");
            textBoxVmasO2.Text = vmasconfig.O2Warning.ToString("0.0");
            textBoxVmasLljll.Text = vmasconfig.Lljll.ToString("0.0");
            textBoxVmasWqll.Text = vmasconfig.Wqll.ToString("0.0");
            textBoxVmasXsb.Text = vmasconfig.Xsb.ToString("0.000");
            textBoxVmasJzgl.Text = vmasconfig.Gljz.ToString("0.0");
            textBoxVmasLxcc.Text = vmasconfig.Lxcc.ToString("0.0");
            textBoxVmasLjcc.Text = vmasconfig.Ljcc.ToString("0.0");
            textBoxVmas3kmcc.Text = vmasconfig.cc3km.ToString("0.0");
            textBoxVmasDssj.Text = vmasconfig.Dssj.ToString("0");
            textBoxVmasNdccsj.Text = vmasconfig.ndccsj.ToString("0");
            checkBoxVmasSdjk.Checked = vmasconfig.SpeedMonitor;

            checkBoxVmasDisableOldStd.Checked= vmasconfig.DisableSpeedOldMonitor;
            checkBoxVmasJzgljk.Checked = vmasconfig.PowerMonitor;
            checkBoxVmasNdjk.Checked = vmasconfig.ConcentrationMonitor;
            checkBoxVmasLljk.Checked = vmasconfig.FlowMonitorr;
            checkBoxVmasXsbjk.Checked = vmasconfig.ThinnerratioMonitor;
            checkBoxVmasHjyjk.Checked = vmasconfig.Huanjingo2Monitor;
            checkBoxVmasCyljk.Checked = vmasconfig.RemainedMonitor;
            checkBoxVmasFlowback.Checked = vmasconfig.Flowback;
            checkBoxVmasZero.Checked = vmasconfig.IfFqyTl;
            checkBoxVmasDisplayData.Checked = vmasconfig.IfDisplayData;
            checkBoxVmasSureTemp.Checked = vmasconfig.IfSureTemp;
            checkBoxVmasYw.Checked = vmasconfig.IsTestYw;
            checkBoxAutoRestart.Checked = vmasconfig.AutoRestart;
            radioButtonVmasAccelerateProcess.Checked = !vmasconfig.IsWholeProcessJK;
            radioButtonVmasWholeProcess.Checked = vmasconfig.IsWholeProcessJK;
            checkBoxVMAS_CO2ANDO2.Checked = vmasconfig.SdCo2AndO2Monitor;
            textBoxVmasFlowbackTime.Text = vmasconfig.FlowTime.ToString("0");
            radioButtonCjBeforeTl.Checked = vmasconfig.CjBeforeTl;
            radioButtonCjAfterTl.Checked = !vmasconfig.CjBeforeTl;
            checkBoxVmas_norezero.Checked = vmasconfig.vmasNoReZero;
            checkBoxVmasCtt.Checked = vmasconfig.vmasCttStatus;
            comboBoxVMASdigits.Text = vmasconfig.digits.ToString();
            checkBoxVMASCO2.Checked = vmasconfig.CO2高浓度监控;

            checkBoxVmasLljAutoZero.Checked=vmasconfig.lljAutoZero;
            checkBoxVmasCaculatePoints.Checked = vmasconfig.caculateAllPoints;
            checkBoxVMASLYGY.Checked = vmasconfig.isLYGY;
            checkBoxUseNewCurve.Checked = vmasconfig.useNewCurve;

            textBoxAsmNdz.Text = asmconfig.Ndz.ToString("0.0");
            textBoxAsmGlwc.Text = asmconfig.Gljz.ToString("0.0");
            textBoxAsmCcsj.Text = asmconfig.Lxcc.ToString("0.0");
            textBoxAsmFlowtime.Text = asmconfig.FlowTime.ToString("0");
            checkBoxAsmSdjk.Checked = asmconfig.SpeedMonitor;
            checkBox05Sdjk.Checked = asmconfig.Speed05Monitor;
            checkBoxAsmGljk.Checked = asmconfig.PowerMonitor;
            checkBoxAsmNdjk.Checked = asmconfig.ConcentrationMonitor;
            checkBoxAsmClljk.Checked = asmconfig.RemainedMonitor;
            checkBoxAsmFlowback.Checked = asmconfig.Flowback;
            checkBoxAsmZero.Checked = asmconfig.IfFqyTl;
            checkBoxASM_saveAllDataSeconds.Checked = asmconfig.saveAllDataSeconds;
            checkBoxAsmDispData.Checked = asmconfig.IfDisplayData;
            checkBoxAsmSuretemp.Checked = asmconfig.IfSureTemp;
            checkBoxASMyw.Checked = asmconfig.IsTestYw;
            checkBoxKsgk.Checked = asmconfig.IsKsgkUsed;
            checkBoxAsmHalfXzKsgk.Checked = asmconfig.IsAsmHalfXzKsgk;
            comboBoxYWJ_ASM.Text = asmconfig.Ywj;
            checkBoxAsm_nozero.Checked = asmconfig.asmNoReZero;
            radioButtonAsmBeforeCjTl.Checked = asmconfig.CjBeforeTl;
            radioButtonAsmAfterCjTl.Checked = !asmconfig.CjBeforeTl;
            checkBoxASMKspd.Checked = asmconfig.asmKspd;
            checkBoxASMKspd2.Checked = asmconfig.asmKspd2;
            checkBoxASMEnableXz.Checked = asmconfig.asmEnableXz;
            comboBoxASMdigits.Text = asmconfig.digits.ToString();
            checkBoxASMFastOnce.Checked = asmconfig.oneTimeFast;
            radioButtonASMPD_small.Checked = asmconfig.isSmallThanXz;
            radioButtonASMPD_smallandequal.Checked = !asmconfig.isSmallThanXz;
            checkBoxAsmZsJk.Checked = asmconfig.asmZsJk;

            panelLugdown_lbgl.Visible = isAdmin;
            textBoxLugDownMinSpeed.Text = lugdownconfig.MinSpeed.ToString("0");
            textBoxLugDownMaxSpeed.Text = lugdownconfig.MaxSpeed.ToString("0");
            
            checkBoxLugdownSureTemp.Checked = lugdownconfig.IfSureTemp;
            checkBoxLugdownZsPd.Checked = lugdownconfig.isFdjzsJudge;
            checkBoxLugdownJudgeSpeed.Checked = lugdownconfig.judgeSpeed;
            checkBoxLugdownYw.Checked = lugdownconfig.IsTestYw;
            comboBoxYWJ_LUGDOWN.Text = lugdownconfig.Ywj;
            radioButtonLugMaxHpGlsm.Checked = (lugdownconfig.LugdownMaxHpStyle == 0);
            radioButtonLugMaxHpVelmaxhp.Checked = (lugdownconfig.LugdownMaxHpStyle == 1);
            radioButtonLugdown_MaxRPM_SD.Checked = (lugdownconfig.maxRPMStyle == 0);
            radioButtonLugdown_MaxRPM_KD.Checked = (lugdownconfig.maxRPMStyle == 1);
            if (lugdownconfig.Glsmms == "恒功率")
            {
                radioButtonLugdownHgl.Checked = true;
                radioButtonLugdownhs.Checked = false;
            }
            else
            {
                radioButtonLugdownHgl.Checked = false;
                radioButtonLugdownhs.Checked = true;
            }
            textBoxLugdownSmpl.Text = lugdownconfig.Smpl.ToString("0");
            checkBoxGSMAXPPD.Checked = lugdownconfig.gsMaxPPD;
            checkBoxGSKCBPD.Checked = lugdownconfig.gsKcbPD;
            checkBoxGSKHGPD.Checked = lugdownconfig.gsKhgPD;
             checkBoxLugdown_sureDW.Checked= lugdownconfig.isSureDW ;
            checkBoxLugdownJcNox.Checked = lugdownconfig.testNOx;
            checkBoxLugdownGljk.Checked = lugdownconfig.LugdownGljk;
            textBoxLug_gljk_value.Text = lugdownconfig.Lugdown_Gljk_value.ToString("0");
            checkBoxLugdown_glsm_ydjk.Checked = lugdownconfig.isYdjk_glsm;
            checkBoxLugdown_cl_ydjk.Checked = lugdownconfig.isYdjk_cl;
            textBoxLugdown_glsm_ydjk.Text = lugdownconfig.ydjk_glsm_value.ToString("0.00");
            textBoxLugdown_cl_ydjk.Text = lugdownconfig.ydjk_cl_value.ToString("0.00");
            checkBoxLudown_prepare.Checked = lugdownconfig.IsLugdownPrepare;
            checkBoxJzjsDisplayData.Checked = lugdownconfig.IsDisplayData;
            textBoxJzjsMinutes.Text = lugdownconfig.maxJzjsMinutes.ToString();
            checkBoxLugdown_60sds.Checked = lugdownconfig.is60sds;
            checkBoxLugdownRecord60s.Checked = lugdownconfig.record60sdsdata;
            checkBoxLugdown_ydjcheck.Checked = lugdownconfig.isCheckYdj;
            comboBoxLudowndigits.Text = lugdownconfig.digits.ToString();
            checkBoxLugdown_ReTimer.Checked = lugdownconfig.reTimer;
            checkBoxSYCO2TS.Checked = lugdownconfig.SYCO2TS;
            checkBoxLugdownZsjk.Checked = lugdownconfig.ZsJk;
            checkBoxLudown_Ywjk.Checked = lugdownconfig.YwJk;
            checkBoxGlsmjk.Checked = lugdownconfig.Glsmjk;


            textBoxSdsFlowtime.Text = sdsconfig.FlowTime.ToString("0");
            textBoxSdsNdz.Text = sdsconfig.Ndz.ToString("0.0");
            textBoxSdsZscc.Text = sdsconfig.Zscc.ToString("0");
            checkBoxSdsFlowback.Checked = sdsconfig.Flowback;
            checkBoxSdsZero.Checked = sdsconfig.IfFqyTl;
            checkBoxSdsNdjk.Checked = sdsconfig.ConcentrationMonitor;
            checkBoxSdsZsjk.Checked = sdsconfig.RotateSpeedMonitor;
            checkBoxSdsYw.Checked = sdsconfig.IsTestYw;
            comboBoxYWJ_SDS.Text = sdsconfig.Ywj;
            comboBox3500.SelectedIndex = sdsconfig.TimerMode3500;
            comboBoxHPrepare.SelectedIndex = sdsconfig.TimerModeHP;
            comboBoxHTest.SelectedIndex = sdsconfig.TimerModeHT;
            comboBoxLPrepare.SelectedIndex = sdsconfig.TimerModeLP;
            comboBoxLTest.SelectedIndex = sdsconfig.TimerModeLT;
            checkBoxSdsSureTemp.Checked = sdsconfig.IsSureTemp;
            checkBoxSds_norezero.Checked = sdsconfig.sdsNoReZero;
            checkBoxLAMBDA_HIGH.Checked = sdsconfig.sdsHighLambdaMonitor;
            checkBoxLAMBDA_LOW.Checked = sdsconfig.sdsLowLambdaMonitor;
            checkBoxSdsDisplayData.Checked = sdsconfig.IfDisplayData;
            comboBoxSDSdigits.Text = sdsconfig.digits.ToString();
            checkBoxFinishHigh.Checked = sdsconfig.finishWhenNoPassHigh;
            checkBoxSdsXz70Zs.Checked= sdsconfig.xz70zs;
            checkBoxSdsLambdaPD.Checked = sdsconfig.noPassWhenLambdEquialXz;
            checkBoxSDS_CGQZSJK.Checked = sdsconfig.CGQZSJK;
            checkBoxSDS_YWJK.Checked = sdsconfig.YWJK;

            textBoxBtgDyzs.Text = btgconfig.Dyzs.ToString("0");
            checkBoxBtgZsjk.Checked = btgconfig.RotateSpeedMonitor;
            checkBoxBtgYw.Checked = btgconfig.IsTestYw;
            comboBoxBTGCFCS.Text = btgconfig.Btgcfcs.ToString();
            comboBoxBTGCLCS.Text = btgconfig.btgclcs.ToString();
            checkBoxBtgManualTantou.Checked = btgconfig.BtgManualTantou;
            checkBoxBTGJHGCJK.Checked = btgconfig.jhzsgcjk;
            comboBoxYWJ_BTG.Text = btgconfig.Ywj;
            if (btgconfig.btgDszsValue == 0) radioButtonBTGDSZS.Checked = true;
            else radioButtonBTGDYZS.Checked = true;
            checkBoxBtg_cl_ydjk.Checked = btgconfig.isYdjk;
            textBoxBtg_cl_ydjk.Text = btgconfig.ydjk_value.ToString("0.00");
            checkBoxBtgDisplayData.Checked = btgconfig.IfDisplayData;
            comboBoxBTGdigits.Text = btgconfig.digits.ToString();
            textBoxBtgMinutes.Text = btgconfig.btgMinutes.ToString();
            checkBoxBtgCheckYdj.Checked = btgconfig.isCheckYdj;
            checkBoxBtgSaveCfProcessData.Checked = btgconfig.saveCfProcessData;
            checkBoxBtg_TimerAfterDs.Checked= btgconfig.TimerAfterDs;


            comboBoxDynZsj.Text = dynconfig.Zsj;
            comboBoxDynZsjCk.Text = dynconfig.Zsjck;
            textBoxDynZs.Text = dynconfig.cczs.ToString("0");
            textBoxDynZsTime.Text = dynconfig.stableTime.ToString("0");
            textBoxDynForceTime.Text = dynconfig.forceTime.ToString("0");
            textBoxFuelForceTime.Text = dynconfig.FuelforceTime.ToString("0");
            textBoxFuelForceQj.Text = dynconfig.FuelForceQj.ToString("0");
            textBoxFuelSdQj.Text = dynconfig.FuelSdQj.ToString("0.0");
            textBoxDynForceQj.Text = dynconfig.DynForceQj.ToString("0");
            radioButtonDynZdyk.Checked = (dynconfig.DynYkStyle == 0);
            radioButtonDynWjyk.Checked= (dynconfig.DynYkStyle == 1);
            comboBoxDynYkTd.Text = dynconfig.DynWjyktd.ToString();
            radioButtonDynReStartForm15.Checked = (dynconfig.DynReStartStyle == 1);
            radioButtonDynReStartFrom60.Checked = (dynconfig.DynReStartStyle == 0);
            checkBoxDynGddw.Checked = dynconfig.DynUseGddw;
            checkBoxDynYkdw.Checked = dynconfig.DynUseYkdw;
            textBoxDynGddwTime.Text = dynconfig.DynGddwTime.ToString("0");
            checkBoxDynJkYh.Checked = dynconfig.DynFuelJk;
            textBoxDynYhxz.Text = dynconfig.DynFuelXz.ToString("0.00");
            textBoxFuelTestFjcs.Text = dynconfig.FuelTestFjjs.ToString("0");
            textBoxDynSdqj.Text = dynconfig.DynSdqj.ToString("0.0");
            textBoxDynMaxWaitTime.Text = dynconfig.DynMaxWaitTime.ToString("0");
            textBoxDynVwSdqj.Text = dynconfig.DynVwSdqj.ToString("0.0");
            textBoxDynYkKey.Text = dynconfig.DynYkKey;
            radioButtonDynFileJson.Checked = (dynconfig.DynFileStyle == 0);
            radioButtonDynFileIni.Checked = (dynconfig.DynFileStyle == 1);
            checkBoxDynStopUnstable.Checked= dynconfig.DynStopUnstable;
            textBoxDynUnstableTime.Text= dynconfig.DynUnstableTime.ToString();

            checkBoxDYNTL.Checked = dynconfig.DynTl;
            checkBoxDynBackTest.Checked = dynconfig.DynBackTest;
            checkBoxDynCO2Test.Checked = dynconfig.DynCO2Test;
            checkBoxDynFlowBack.Checked = dynconfig.DynFlowBack;
            checkBoxDynYkqr.Checked = dynconfig.DynYkqr;
            checkBoxDynManulKey.Checked = dynconfig.DynUseManualKey;

            //comboBoxBPQCOM.Text = equipconfig.BpqCom;
            //comboBoxBPQDY.Text = equipconfig.BpqDy.ToString();
            //comboBoxBPQFS.Text = equipconfig.BpqMethod;
            //comboBoxBPQXH.Text = equipconfig.BpqXh;
            comboBoxFAN.Text = equipconfig.HeatFan.ToString();
            comboBoxEmergency.Text = equipconfig.EmergencyStop.ToString();



            comboBoxDYNVersion.Text = equipconfig.igbtVersion;
            if (equipconfig.Cgjifpz == false)
                comboBoxCgjxh.Text = "无";
            else
                comboBoxCgjxh.Text = equipconfig.Cgjxh;
            comboBoxCgjck.Text = equipconfig.Cgjck;
            if (equipconfig.Fqyifpz == false)
                comboBoxFqyxh.Text = "无";
            else
                comboBoxFqyxh.Text = equipconfig.Fqyxh;
            comboBoxFqyck.Text = equipconfig.Fqyck;
            if (equipconfig.Ydjifpz == false)
                comboBoxYdjxh.Text = "无";
            else
                comboBoxYdjxh.Text = equipconfig.Ydjxh;
            checkBoxOldMqy200.Checked = equipconfig.IsOldMqy200;
            comboBoxYdjck.Text = equipconfig.Ydjck;
            if (equipconfig.Lzydjifpz == false)
                comboBoxLZYDJXH.Text = "无";
            else
                comboBoxLZYDJXH.Text = equipconfig.Lzydjxh;
            comboBoxLZYDJCK.Text = equipconfig.Lzydjck;
            if (equipconfig.Lljifpz == false)
                comboBoxLljxh.Text = "无";
            else
                comboBoxLljxh.Text = equipconfig.Lljxh;
            comboBoxLljck.Text = equipconfig.Lljck;
            if (equipconfig.isYhyPz == false)
                comboBoxYhyxh.Text = "无";
            else
                comboBoxYhyxh.Text = equipconfig.YhyXh;
            comboBoxYhyck.Text = equipconfig.YhyCk;
            if (equipconfig.NOxifpz == false)
                comboBoxNOxXh.Text = "无";
            else
                comboBoxNOxXh.Text = equipconfig.NOxXh;
            comboBoxNOxCk.Text = equipconfig.NOxCk;
            if (equipconfig.Ledifpz == false)
                comboBoxLEDck.Text = "未配置";
            else
                comboBoxLEDck.Text = equipconfig.Ledck;
            comboBoxCOMXCE.Text = equipconfig.Xce100ck;
            comboBoxXCECOMSTRING.Text = equipconfig.Xce100Comstring;
            comboBoxLEDXH.Text = equipconfig.Ledxh;
            comboBoxLEDCOMSTRING.Text = equipconfig.LedComstring;
            comboBoxTemp.Text = equipconfig.TempInstrument;
            comboBoxCgjckpzz.Text = equipconfig.cgjckpzz;
            comboBoxFqyckppz.Text=equipconfig.Fqyckpzz ;
            comboBoxYdjckppz.Text=equipconfig.Ydjckpzz ;
            comboBoxLljckpzz.Text = equipconfig.Lljckpzz;
            comboBoxYhyckpz.Text = equipconfig.YhjCkpz;
            comboBoxNOxCkpz.Text = equipconfig.NOxCkpz;
            comboBoxLZCKPZZ.Text = equipconfig.Lzckpzz;
            comboBoxDriverScreen.SelectedIndex = equipconfig.DriverDisplay;
            comboBoxDisplayMethod.Text = equipconfig.DisplayMethod;
            comboBoxDriveFbl.SelectedIndex = equipconfig.DriverFbl;
            textBoxFqyxysj.Text = equipconfig.FqyDelayTime.ToString();
            textBoxLLjO2xysj.Text = equipconfig.LljDelayTime.ToString();
            textBoxLugdownWdsj.Text = equipconfig.LugdownWdsj.ToString();
            comboBoxWorkMode.SelectedIndex = (equipconfig.WorkAutomaticMode ? 0 : 1);
            textBoxBrakePWM.Text = equipconfig.BrakePWM.ToString();
            textBoxYdjL.Text = equipconfig.YdjL.ToString();
            comboBoxCgjNz.SelectedIndex = equipconfig.CgjNz;
            comboBoxCarGd.Text = equipconfig.CarGdChanel.ToString();
            comboBox10CB_FL.Text = equipconfig.CGJ10CB_FL.ToString();
            //checkBoxGdyk.Checked = equipconfig.isIgbtContainGdyk;
            checkBoxIsFqyNhSelfUse.Checked = equipconfig.isFqyNhSelfUse;
            checkBoxIsYdjNhSelfUse.Checked = equipconfig.isYdjNhSelfUse;
            checkBoxIsLljNhSelfUse.Checked = equipconfig.isLljNhSelfUse;

             checkBoxYDJ_UseLinearValue.Checked = equipconfig.isYdjUseLinearValue;
            comboBoxLEDROW1.Text = equipconfig.ledrow1.ToString();
            comboBoxLEDROW2.Text = equipconfig.ledrow2.ToString();
            comboBoxLEDTJPH.Text = equipconfig.LEDTJPH.ToString();
            checkBoxDisplayJudge.Checked = equipconfig.displayJudge;
            textBoxLZYDJADD.Text = equipconfig.lzydjadd;
            textBoxBackGroundTime.Text = equipconfig.BackGroundTestTime.ToString();
            textBoxCanliHCTime.Text = equipconfig.CanliHCTestTime.ToString();


            checkBoxUseWeightWCF.Checked=equipconfig.useWeightWCF ;
            textBoxWeightWCF.Text=equipconfig.WeightWCFaddress;
            checkBoxJHJK.Checked = equipconfig.useJHJK;
            checkBoxJH_SCREEN.Checked = equipconfig.useJHSCREEN;
            checkBoxHideDriverData.Checked = equipconfig.HideDriverData;
            
            textBoxJHLBGLYJZ.Text=equipconfig.JHLBGLB.ToString("0");
            textBoxJHLAMBDAMIN.Text=equipconfig.JHLAMBDAMIN.ToString("0.00");
            textBoxJHLAMBDAMAX.Text=equipconfig.JHLAMBDAMAX.ToString("0.00");
            comboBoxDataSecondsType.Text = equipconfig.DATASECONDS_TYPE;
            /*comboBoxZZYXH.Text = equipconfig.ZzyXh;
            comboBoxZZYCK.Text = equipconfig.ZzyCk;
            comboBoxZZYCKPZ.Text = equipconfig.ZzyCkpzz;
            comboBoxZZSURESTYLE.SelectedIndex = equipconfig.ZzSureStyle;
            comboBoxZzGd.Text = equipconfig.ZzGdChanel.ToString();
            comboBoxLEFTZZCHANEL.Text = equipconfig.LeftZzChanel.ToString();
            comboBoxRIGHTZZCHANEL.Text = equipconfig.RightZzChanel.ToString();*/

            comboBoxTMQCK.Text = equipconfig.Tmqck;
            comboBoxTMQPZ.Text = equipconfig.Tmqckpz;
            comboBoxTMQXH.Text = equipconfig.Tmqxh;
            checkBoxTPWSD.Checked = equipconfig.isTpTempInstrument;
            checkBoxCD_FQY.Checked = equipconfig.cd_fqy;
            checkBoxCD_YDJ.Checked = equipconfig.cd_ydj;
            checkBoxNHSJZ.Checked = equipconfig.IsUseNhSjz;
            comboBoxNHSJZ_COM.Text = equipconfig.NhSjz_Com;
            comboBoxNHSJZ_COMSTRING.Text = equipconfig.NhSjz_ComString;
            checkBoxZSJ_ZD.Checked = rotateconfig.ZsjIsEnable_ZD;
            comboBoxZSJCOM_ZD.Text = rotateconfig.ZsjCom_ZD;
            comboBoxZSJCOMPZ_ZD.Text = rotateconfig.ZsjPz_ZD;
            checkBoxZSJ_DY.Checked = rotateconfig.ZsjIsEnable_DY;
            comboBoxZSJCOM_DY.Text = rotateconfig.ZsjCom_DY;
            comboBoxZSJCOMPZ_DY.Text = rotateconfig.ZsjPz_DY;
            checkBoxZSJ_OBD.Checked = rotateconfig.ZsjIsEnable_OBD;
            comboBoxZSJCOM_OBD.Text = rotateconfig.ZsjCom_OBD;
            comboBoxZSJCOMPZ_OBD.Text = rotateconfig.ZsjPz_OBD;
            comboBoxZSJ_CY.Text = rotateconfig.CyZsjDefault;
            comboBoxZSJ_QY.Text = rotateconfig.QyZsjDefault;
            comboBoxZSJXH_ZD.Text = rotateconfig.ZsjXh_ZD;
            comboBoxZSJXH_DY.Text = rotateconfig.ZsjXh_DY;
            comboBoxZSJXH_OBD.Text = rotateconfig.ZsjXh_OBD;
            checkBoxNOxIsContainYDJ.Checked = equipconfig.NOxIsContainYDJ;
            comboBoxJcxLx.SelectedIndex = equipconfig.JCXLX;
            textBoxCgjR.Text = equipconfig.CGJR.ToString("0");
            textBoxYwBaseValue.Text = equipconfig.ywBaseValue.ToString("0.0");
            comboBoxLambdaxs.Text = equipconfig.lambdaXs.ToString("0");
            checkBoxCheckLock.Checked = equipconfig.checkLock;
            checkBoxOBD监控.Checked = equipconfig.OBDJK;
            checkBoxYdjUseK.Checked = equipconfig.YdjJzUseK;
            textBoxCarryTantouTime.Text = equipconfig.CarryTantouTime.ToString();
            checkBoxLiftUpAfterStop.Checked = equipconfig.liftUpAfterStop;

            checkBoxManualSave.Checked = equipconfig.ManualSaveData;
            checkBoxUploadRealTime.Checked = equipconfig.UploadRealTimeData;
            checkBoxJNDL_DISP.Checked = equipconfig.isJNDLDisplay;
            checkBoxZeroAfterTest.Checked = equipconfig.isZeroAfterTest;
            checkBoxOBDYW.Checked = equipconfig.useOBDYWFirst;
            comboBoxFqyZeroMode.SelectedIndex = (int)(equipconfig.FxyZeroMode);
            comboBoxNOxFxyZeroMode.SelectedIndex = (int)(equipconfig.NOxFxyZeroMode);
            comboBoxCGJ_ServerIP.Text = equipconfig.CGJ_ServerIP;
            comboBoxCGJ_LocalIP.Text = equipconfig.CGJ_LocalIP;
            comboBoxCGJ_ServerPort.Text = equipconfig.CGJ_ServerPort.ToString();
            comboBoxCGJ_LocalPort.Text = equipconfig.CGJ_LocalPort.ToString();
        }

        private void buttonVmasSave_Click(object sender, EventArgs e)
        {
            try
            {
                carinfor.VmasConfigInfdata vmasconfig = configini.getVmasConfigIni();
                vmasconfig.Ndz = float.Parse(textBoxVmasNdz.Text);
                vmasconfig.O2Warning = double.Parse(textBoxVmasO2.Text);
                vmasconfig.Lljll = float.Parse(textBoxVmasLljll.Text);
                vmasconfig.Wqll = float.Parse(textBoxVmasWqll.Text);
                vmasconfig.Xsb = float.Parse(textBoxVmasXsb.Text);
                vmasconfig.Gljz = float.Parse(textBoxVmasJzgl.Text);
                vmasconfig.Lxcc = float.Parse(textBoxVmasLxcc.Text);
                vmasconfig.Ljcc = float.Parse(textBoxVmasLjcc.Text);
                vmasconfig.cc3km = float.Parse(textBoxVmas3kmcc.Text);
                vmasconfig.Dssj = int.Parse(textBoxVmasDssj.Text);
                vmasconfig.ndccsj = int.Parse(textBoxVmasNdccsj.Text);
                vmasconfig.FlowTime = int.Parse(textBoxVmasFlowbackTime.Text);
                vmasconfig.SpeedMonitor = checkBoxVmasSdjk.Checked;
                vmasconfig.DisableSpeedOldMonitor = checkBoxVmasDisableOldStd.Checked;

                vmasconfig.PowerMonitor = checkBoxVmasJzgljk.Checked;
                vmasconfig.ConcentrationMonitor = checkBoxVmasNdjk.Checked;
                vmasconfig.SdCo2AndO2Monitor = false;// checkBoxVMAS_CO2ANDO2.Checked;
                vmasconfig.FlowMonitorr = checkBoxVmasLljk.Checked;
                vmasconfig.ThinnerratioMonitor = checkBoxVmasXsbjk.Checked;
                vmasconfig.Huanjingo2Monitor = checkBoxVmasHjyjk.Checked;
                vmasconfig.RemainedMonitor = checkBoxVmasCyljk.Checked;
                vmasconfig.Flowback = checkBoxVmasFlowback.Checked;
                vmasconfig.IfFqyTl = checkBoxVmasZero.Checked;
                vmasconfig.IfDisplayData = checkBoxVmasDisplayData.Checked;
                vmasconfig.IfSureTemp = checkBoxVmasSureTemp.Checked;
                vmasconfig.IsTestYw = checkBoxVmasYw.Checked;
                vmasconfig.AutoRestart = checkBoxAutoRestart.Checked;
                vmasconfig.IsWholeProcessJK = radioButtonVmasWholeProcess.Checked;
                vmasconfig.CjBeforeTl = radioButtonCjBeforeTl.Checked;
                vmasconfig.vmasNoReZero = checkBoxVmas_norezero.Checked;
                vmasconfig.vmasCttStatus = checkBoxVmasCtt.Checked;
                vmasconfig.digits = int.Parse(comboBoxVMASdigits.Text);
                vmasconfig.CO2高浓度监控 = checkBoxVMASCO2.Checked;
                vmasconfig.lljAutoZero = checkBoxVmasLljAutoZero.Checked;
                vmasconfig.caculateAllPoints = checkBoxVmasCaculatePoints.Checked;
                vmasconfig.isLYGY = checkBoxVMASLYGY.Checked;
                vmasconfig.useNewCurve = checkBoxUseNewCurve.Checked;
                if (configini.writeVmasConfigIni(vmasconfig))
                    MessageBox.Show("保存成功.", "系统提示");
                else
                    MessageBox.Show("数据输入有误,请检查.", "未成功保存");
            }
            catch(Exception er)
            {
                MessageBox.Show("保存出错,异常信息:"+er.Message, "未成功保存");
            }
        }

        private void buttonAsmSave_Click(object sender, EventArgs e)
        {
            carinfor.AsmConfigInfdata asmconfig = configini.getAsmConfigIni();

            asmconfig.Ndz = float.Parse(textBoxAsmNdz.Text);
            asmconfig.Gljz = float.Parse(textBoxAsmGlwc.Text);
            asmconfig.Lxcc = float.Parse(textBoxAsmCcsj.Text);
            asmconfig.FlowTime = int.Parse(textBoxAsmFlowtime.Text);
            asmconfig.SpeedMonitor = checkBoxAsmSdjk.Checked;
            asmconfig.Speed05Monitor = checkBox05Sdjk.Checked;
            asmconfig.PowerMonitor = checkBoxAsmGljk.Checked;
            asmconfig.ConcentrationMonitor = checkBoxAsmNdjk.Checked;
            asmconfig.RemainedMonitor = checkBoxAsmClljk.Checked;
            asmconfig.Flowback = checkBoxAsmFlowback.Checked;
            asmconfig.IfFqyTl = checkBoxAsmZero.Checked;
            asmconfig.saveAllDataSeconds = checkBoxASM_saveAllDataSeconds.Checked;
            asmconfig.IfDisplayData = checkBoxAsmDispData.Checked;
            asmconfig.IfSureTemp = checkBoxAsmSuretemp.Checked;
            asmconfig.IsTestYw = checkBoxASMyw.Checked;
            asmconfig.IsKsgkUsed = checkBoxKsgk.Checked;
            asmconfig.IsAsmHalfXzKsgk = checkBoxAsmHalfXzKsgk.Checked;
            asmconfig.Ywj = comboBoxYWJ_ASM.Text;
            asmconfig.asmNoReZero = checkBoxAsm_nozero.Checked;

            asmconfig.CjBeforeTl = radioButtonAsmBeforeCjTl.Checked;
            asmconfig.asmKspd = checkBoxASMKspd.Checked;
            asmconfig.asmKspd2 = checkBoxASMKspd2.Checked;
            asmconfig.asmEnableXz = checkBoxASMEnableXz.Checked;
            asmconfig.digits = int.Parse(comboBoxASMdigits.Text);
            asmconfig.oneTimeFast = checkBoxASMFastOnce.Checked;
            asmconfig.isSmallThanXz = radioButtonASMPD_small.Checked;
            asmconfig.asmZsJk = checkBoxAsmZsJk.Checked;
            if (configini.writeAsmConfigIni(asmconfig))
                MessageBox.Show("保存成功.", "系统提示");
            else
                MessageBox.Show("数据输入有误,请检查.", "未成功保存");
        }

        private void buttonLugdownSave_Click(object sender, EventArgs e)
        {
            try
            {
                carinfor.LugdownConfigInfdata lugdownconfig = configini.getLugdownConfigIni();
                lugdownconfig.MinSpeed = int.Parse(textBoxLugDownMinSpeed.Text);
                lugdownconfig.MaxSpeed = float.Parse(textBoxLugDownMaxSpeed.Text);
                lugdownconfig.Smpl = int.Parse(textBoxLugdownSmpl.Text);
                lugdownconfig.IfSureTemp = checkBoxLugdownSureTemp.Checked;
                lugdownconfig.isFdjzsJudge = checkBoxLugdownZsPd.Checked;
                lugdownconfig.judgeSpeed = checkBoxLugdownJudgeSpeed.Checked;
                lugdownconfig.gsMaxPPD = checkBoxGSMAXPPD.Checked;
                lugdownconfig.gsKcbPD = checkBoxGSKCBPD.Checked;
                lugdownconfig.gsKhgPD = checkBoxGSKHGPD.Checked;
                lugdownconfig.isSureDW = checkBoxLugdown_sureDW.Checked;
               
                lugdownconfig.IsTestYw = checkBoxLugdownYw.Checked;
                lugdownconfig.IsDisplayData = checkBoxJzjsDisplayData.Checked;
                lugdownconfig.Glsmms = (radioButtonLugdownHgl.Checked) ? "恒功率" : "恒速度";
                lugdownconfig.LugdownMaxHpStyle = (radioButtonLugMaxHpVelmaxhp.Checked) ? 1 : 0;
                lugdownconfig.maxRPMStyle = (radioButtonLugdown_MaxRPM_SD.Checked) ? 0 : 1;
                lugdownconfig.testNOx = checkBoxLugdownJcNox.Checked;
                lugdownconfig.LugdownGljk = checkBoxLugdownGljk.Checked;
                lugdownconfig.Lugdown_Gljk_value = float.Parse(textBoxLug_gljk_value.Text);
                lugdownconfig.Ywj = comboBoxYWJ_LUGDOWN.Text;
                lugdownconfig.isYdjk_glsm = checkBoxLugdown_glsm_ydjk.Checked;
                lugdownconfig.ydjk_glsm_value = double.Parse(textBoxLugdown_glsm_ydjk.Text);
                lugdownconfig.isYdjk_cl = checkBoxLugdown_cl_ydjk.Checked;
                lugdownconfig.ydjk_cl_value = double.Parse(textBoxLugdown_cl_ydjk.Text);
                lugdownconfig.IsLugdownPrepare = checkBoxLudown_prepare.Checked;
                lugdownconfig.maxJzjsMinutes = int.Parse(textBoxJzjsMinutes.Text);
                lugdownconfig.isCheckYdj = checkBoxLugdown_ydjcheck.Checked;
                lugdownconfig.is60sds = checkBoxLugdown_60sds.Checked;
                lugdownconfig.record60sdsdata = checkBoxLugdownRecord60s.Checked;
                lugdownconfig.digits = int.Parse(comboBoxLudowndigits.Text);
                lugdownconfig.reTimer = checkBoxLugdown_ReTimer.Checked;
                lugdownconfig.SYCO2TS = checkBoxSYCO2TS.Checked;
                lugdownconfig.ZsJk = checkBoxLugdownZsjk.Checked;
                lugdownconfig.YwJk = checkBoxLudown_Ywjk.Checked;
                lugdownconfig.Glsmjk = checkBoxGlsmjk.Checked;
                if (lugdownconfig.Lugdown_Gljk_value > 80f || lugdownconfig.Lugdown_Gljk_value < 20f)
                {
                    MessageBox.Show("加载功率规定值范围为20~80", "数值输入超出范围");
                    return;
                }
                if (configini.writeLugdownConfigIni(lugdownconfig))
                    MessageBox.Show("保存成功.", "系统提示");
                else
                    MessageBox.Show("数据输入有误,请检查.", "未成功保存");
            }
            catch
            {
                MessageBox.Show("数据输入有误,请检查.", "未成功保存");
            }
        }

        private void buttonSdsSave_Click(object sender, EventArgs e)
        {
            carinfor.SdsConfigInfdata sdsconfig = configini.getSdsConfigIni();
            sdsconfig.FlowTime = int.Parse(textBoxSdsFlowtime.Text);
            sdsconfig.Ndz = float.Parse(textBoxSdsNdz.Text);
            sdsconfig.Zscc = int.Parse(textBoxSdsZscc.Text);
            sdsconfig.Flowback = checkBoxSdsFlowback.Checked;
            sdsconfig.IfFqyTl = checkBoxSdsZero.Checked;
            sdsconfig.ConcentrationMonitor = checkBoxSdsNdjk.Checked;
            sdsconfig.RotateSpeedMonitor = checkBoxSdsZsjk.Checked;
            sdsconfig.IsTestYw = checkBoxSdsYw.Checked;
            sdsconfig.IsSureTemp = checkBoxSdsSureTemp.Checked;
            sdsconfig.TimerMode3500 = comboBox3500.SelectedIndex;
            sdsconfig.TimerModeHP = comboBoxHPrepare.SelectedIndex;
            sdsconfig.TimerModeHT = comboBoxHTest.SelectedIndex;
            sdsconfig.TimerModeLP = comboBoxLPrepare.SelectedIndex;
            sdsconfig.TimerModeLT = comboBoxLTest.SelectedIndex;
            sdsconfig.Ywj = comboBoxYWJ_SDS.Text;
            sdsconfig.sdsNoReZero = checkBoxSds_norezero.Checked;
            sdsconfig.sdsHighLambdaMonitor = checkBoxLAMBDA_HIGH.Checked;
            sdsconfig.sdsLowLambdaMonitor = checkBoxLAMBDA_LOW.Checked;
            sdsconfig.IfDisplayData = checkBoxSdsDisplayData.Checked;
            sdsconfig.digits = int.Parse(comboBoxSDSdigits.Text);
            sdsconfig.finishWhenNoPassHigh = checkBoxFinishHigh.Checked;
            sdsconfig.xz70zs = checkBoxSdsXz70Zs.Checked;
            sdsconfig.noPassWhenLambdEquialXz = checkBoxSdsLambdaPD.Checked;
            sdsconfig.CGQZSJK = checkBoxSDS_CGQZSJK.Checked;
            sdsconfig.YWJK = checkBoxSDS_YWJK.Checked;
            if (configini.writeSdsConfigIni(sdsconfig))
                MessageBox.Show("保存成功.", "系统提示");
            else
                MessageBox.Show("数据输入有误,请检查.", "未成功保存");
        }

        private void buttonBtgSave_Click(object sender, EventArgs e)
        {
            carinfor.BtgConfigInfdata btgconfig = configini.getBtgConfigIni();
            btgconfig.Dyzs = int.Parse(textBoxBtgDyzs.Text);
            btgconfig.RotateSpeedMonitor = checkBoxBtgZsjk.Checked;
            btgconfig.jhzsgcjk = checkBoxBTGJHGCJK.Checked;
            btgconfig.IsTestYw = checkBoxBtgYw.Checked;
            btgconfig.Btgcfcs =int.Parse(comboBoxBTGCFCS.Text);
            btgconfig.btgclcs = int.Parse(comboBoxBTGCLCS.Text);
            btgconfig.BtgManualTantou = checkBoxBtgManualTantou.Checked;
            btgconfig.btgDszsValue = radioButtonBTGDSZS.Checked ? 0 : 1;
            btgconfig.Ywj = comboBoxYWJ_BTG.Text;
            btgconfig.isYdjk = checkBoxBtg_cl_ydjk.Checked;
            btgconfig.ydjk_value = double.Parse(textBoxBtg_cl_ydjk.Text);
            btgconfig.IfDisplayData = checkBoxBtgDisplayData.Checked;
            btgconfig.digits = int.Parse(comboBoxBTGdigits.Text);
            btgconfig.btgMinutes = int.Parse(textBoxBtgMinutes.Text);
            btgconfig.isCheckYdj = checkBoxBtgCheckYdj.Checked;
            btgconfig.saveCfProcessData = checkBoxBtgSaveCfProcessData.Checked;
            btgconfig.TimerAfterDs = checkBoxBtg_TimerAfterDs.Checked;
            if (configini.writeBtgConfigIni(btgconfig))
                MessageBox.Show("保存成功.", "系统提示");
            else
                MessageBox.Show("数据输入有误,请检查.", "未成功保存");
        }

        private void buttonSaveEquipment_Click(object sender, EventArgs e)
        {
            carinfor.equipmentConfigInfdata equipconfig = configini.getEquipConfigIni();
            if (comboBoxCgjxh.Text == "无")
                equipconfig.Cgjifpz = false;
            else
            {
                equipconfig.Cgjifpz = true;
                equipconfig.Cgjxh = comboBoxCgjxh.Text;
                equipconfig.Cgjck = comboBoxCgjck.Text;
            }
            if (comboBoxFqyxh.Text == "无")
                equipconfig.Fqyifpz = false;
            else
            {
                equipconfig.Fqyifpz = true;
                equipconfig.Fqyxh = comboBoxFqyxh.Text;
                equipconfig.Fqyck = comboBoxFqyck.Text;
            }
            if (comboBoxYdjxh.Text == "无")
                equipconfig.Ydjifpz = false;
            else
            {
                equipconfig.Ydjifpz = true;
                equipconfig.Ydjxh = comboBoxYdjxh.Text;
                equipconfig.Ydjck = comboBoxYdjck.Text;
            }
            if (comboBoxLZYDJXH.Text == "无")
                equipconfig.Lzydjifpz = false;
            else
            {
                equipconfig.Lzydjifpz = true;
                equipconfig.Lzydjxh = comboBoxLZYDJXH.Text;
                equipconfig.Lzydjck = comboBoxLZYDJCK.Text;
            }
            if (comboBoxLljxh.Text == "无")
                equipconfig.Lljifpz = false;
            else
            {
                equipconfig.Lljifpz = true;
                equipconfig.Lljxh = comboBoxLljxh.Text;
                equipconfig.Lljck = comboBoxLljck.Text;
            }
            if (comboBoxLEDck.Text == "未配置")
                equipconfig.Ledifpz = false;
            else
            {
                equipconfig.Ledifpz = true;
                equipconfig.Ledck = comboBoxLEDck.Text;
            }
            equipconfig.Xce100ck = comboBoxCOMXCE.Text;
            equipconfig.Xce100Comstring =comboBoxXCECOMSTRING.Text;
            equipconfig.Ledxh = comboBoxLEDXH.Text;
            equipconfig.LedComstring = comboBoxLEDCOMSTRING.Text;
            //equipconfig.BpqXh = comboBoxBPQXH.Text;
            //equipconfig.BpqCom = comboBoxBPQCOM.Text;
            //equipconfig.BpqDy = int.Parse(comboBoxBPQDY.Text);
            //equipconfig.BpqMethod = comboBoxBPQFS.Text;
            equipconfig.HeatFan = int.Parse(comboBoxFAN.Text);
            equipconfig.EmergencyStop = int.Parse(comboBoxEmergency.Text);
            equipconfig.Fqyckpzz = comboBoxFqyckppz.Text;
            equipconfig.Ydjckpzz = comboBoxYdjckppz.Text;
            equipconfig.Lljckpzz = comboBoxLljckpzz.Text;
            equipconfig.TempInstrument = comboBoxTemp.Text;
            equipconfig.DisplayMethod = comboBoxDisplayMethod.Text;
            equipconfig.DriverDisplay = comboBoxDriverScreen.SelectedIndex;
            equipconfig.FqyDelayTime = int.Parse(textBoxFqyxysj.Text);
            equipconfig.LljDelayTime = int.Parse(textBoxLLjO2xysj.Text);
            equipconfig.LugdownWdsj = int.Parse(textBoxLugdownWdsj.Text);
            equipconfig.TestStandard = comboBoxHJT.Text;
            
            if (configini.writeEquipmentConfig(equipconfig))
                MessageBox.Show("保存成功.", "系统提示");
            else
                MessageBox.Show("数据输入有误,请检查.", "未成功保存");
        }

        private void comboBoxLugdownZsj_SelectedValueChanged(object sender, EventArgs e)
        {
            if (comboBoxLugdownZsj.Text != "废气仪" && comboBoxLugdownZsj.Text != "烟度计")
            {
                comboBoxLugdownZsjCom.Enabled = true;
            }
            else
            {
                comboBoxLugdownZsjCom.Enabled = false;
            }
        }

       

        

        private void button1_Click(object sender, EventArgs e)
        {
            File.Delete(@".\detectConfig.ini");
            File.Copy(@"D:\exhaustTest\detectConfigBk.ini",@".\detectConfig.ini");
            initConfigInfo();
        }

        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Shift && e.Control && e.KeyCode == Keys.M)
            {
                if (tabPage2.Parent == null)
                {
                    tabPage2.Parent = tabControl1;
                    tabPage3.Parent = tabControl1;
                    tabPage4.Parent = tabControl1;
                    tabPage5.Parent = tabControl1;
                    tabPage6.Parent = tabControl1;
                }
                else
                {
                    tabPage2.Parent = null;
                    tabPage3.Parent = null;
                    tabPage4.Parent = null;
                    tabPage5.Parent = null;
                    tabPage6.Parent = null;
                }
                buttonAsmSave.Visible = !buttonAsmSave.Visible;
                buttonVmasSave.Visible = !buttonVmasSave.Visible;
                buttonSdsSave.Visible = !buttonSdsSave.Visible;
                buttonLugdownSave.Visible = !buttonLugdownSave.Visible;
                buttonBtgSave.Visible = !buttonBtgSave.Visible;
                button1.Visible = !button1.Visible;
                panelASMSETTINGS.Enabled = !panelASMSETTINGS.Enabled;
                panelSDSSETTINGS.Enabled = !panelSDSSETTINGS.Enabled;
                panelVMASSETTINGS.Enabled = !panelVMASSETTINGS.Enabled;
                panelJZJS.Enabled = !panelJZJS.Enabled;
                panelBTG.Enabled = !panelBTG.Enabled;
                panel29.Enabled = !panel29.Enabled;

                panelASM.Visible = !panelASM.Visible;
                panelVMAS.Visible = !panelVMAS.Visible;
                panelSDS.Visible = !panelSDS.Visible;
                checkBoxOBD监控.Visible = !checkBoxOBD监控.Visible;

            }
            if (e.Shift && e.Control && e.KeyCode == Keys.A)
            {
                checkBoxASMKspd.Visible = true;
                checkBoxASMKspd2.Visible = true;
                checkBoxASMEnableXz.Visible = true;
            }
            if (e.Shift && e.Control && e.KeyCode == Keys.V)
            {
                checkBoxVmasLljk.Enabled = true;
                checkBoxVmasHjyjk.Enabled = true;
            }
        }

        private void buttonSaveEquipment_Click_1(object sender, EventArgs e)
        {
            carinfor.equipmentConfigInfdata equipconfig = configini.getEquipConfigIni();
            carinfor.RotateConfigData rotateconfig = configini.getRotateConfigIni();
             equipconfig.igbtVersion= comboBoxDYNVersion.Text;
            if (comboBoxCgjxh.Text == "无")
                equipconfig.Cgjifpz = false;
            else
            {
                equipconfig.Cgjifpz = true;
                equipconfig.Cgjxh = comboBoxCgjxh.Text;
                equipconfig.Cgjck = comboBoxCgjck.Text;
            }
            if (comboBoxFqyxh.Text == "无")
                equipconfig.Fqyifpz = false;
            else
            {
                equipconfig.Fqyifpz = true;
                equipconfig.Fqyxh = comboBoxFqyxh.Text;
                equipconfig.Fqyck = comboBoxFqyck.Text;
            }
            if (comboBoxYdjxh.Text == "无")
                equipconfig.Ydjifpz = false;
            else
            {
                equipconfig.Ydjifpz = true;
                equipconfig.Ydjxh = comboBoxYdjxh.Text;
                equipconfig.Ydjck = comboBoxYdjck.Text;
                equipconfig.IsOldMqy200 = checkBoxOldMqy200.Checked;
            }
            if (comboBoxLZYDJXH.Text == "无")
                equipconfig.Lzydjifpz = false;
            else
            {
                equipconfig.Lzydjifpz = true;
                equipconfig.Lzydjxh = comboBoxLZYDJXH.Text;
                equipconfig.Lzydjck = comboBoxLZYDJCK.Text;
                equipconfig.lzydjadd = textBoxLZYDJADD.Text;
            }
            if (comboBoxLljxh.Text == "无")
                equipconfig.Lljifpz = false;
            else
            {
                equipconfig.Lljifpz = true;
                equipconfig.Lljxh = comboBoxLljxh.Text;
                equipconfig.Lljck = comboBoxLljck.Text;
            }
            if (comboBoxYhyxh.Text == "无")
                equipconfig.isYhyPz = false;
            else
            {
                equipconfig.isYhyPz = true;
                equipconfig.YhyXh = comboBoxYhyxh.Text;
                equipconfig.YhyCk = comboBoxYhyck.Text;
                equipconfig.YhjCkpz = comboBoxYhyckpz.Text;
            }
            if (comboBoxLEDck.Text == "未配置")
                equipconfig.Ledifpz = false;
            else
            {
                equipconfig.Ledifpz = true;
                equipconfig.Ledck = comboBoxLEDck.Text;
            }
            if (comboBoxNOxXh.Text == "无")
                equipconfig.NOxifpz = false;
            else
            {
                equipconfig.NOxifpz = true;
                equipconfig.NOxXh = comboBoxNOxXh.Text;
                equipconfig.NOxCk = comboBoxNOxCk.Text;
            }
            equipconfig.LEDTJPH = int.Parse(comboBoxLEDTJPH.Text);
            equipconfig.ledrow1 = int.Parse(comboBoxLEDROW1.Text);
            equipconfig.ledrow2 = int.Parse(comboBoxLEDROW2.Text);
            equipconfig.BrakePWM = int.Parse(textBoxBrakePWM.Text);
            equipconfig.YdjL = int.Parse(textBoxYdjL.Text);
            equipconfig.Xce100ck = comboBoxCOMXCE.Text;
            equipconfig.Xce100Comstring = comboBoxXCECOMSTRING.Text;
            equipconfig.Ledxh = comboBoxLEDXH.Text;
            equipconfig.LedComstring = comboBoxLEDCOMSTRING.Text;
            //equipconfig.BpqXh = comboBoxBPQXH.Text;
            //equipconfig.BpqCom = comboBoxBPQCOM.Text;
            //equipconfig.BpqDy = int.Parse(comboBoxBPQDY.Text);
            //equipconfig.BpqMethod = comboBoxBPQFS.Text;
            equipconfig.HeatFan = int.Parse(comboBoxFAN.Text);
            equipconfig.EmergencyStop = int.Parse(comboBoxEmergency.Text);
            equipconfig.cgjckpzz = comboBoxCgjckpzz.Text;
            equipconfig.Fqyckpzz = comboBoxFqyckppz.Text;
            equipconfig.Ydjckpzz = comboBoxYdjckppz.Text;
            equipconfig.Lljckpzz = comboBoxLljckpzz.Text;
            equipconfig.NOxCkpz = comboBoxNOxCkpz.Text;
            equipconfig.NOxIsContainYDJ = checkBoxNOxIsContainYDJ.Checked;
            equipconfig.Lzckpzz = comboBoxLZCKPZZ.Text;
            equipconfig.TempInstrument = comboBoxTemp.Text;
            equipconfig.DisplayMethod = comboBoxDisplayMethod.Text;
            equipconfig.DriverDisplay = comboBoxDriverScreen.SelectedIndex;
            equipconfig.displayJudge = checkBoxDisplayJudge.Checked;
            equipconfig.DriverFbl = comboBoxDriveFbl.SelectedIndex;
            equipconfig.FqyDelayTime = int.Parse(textBoxFqyxysj.Text);
            equipconfig.LljDelayTime = int.Parse(textBoxLLjO2xysj.Text);
            equipconfig.LugdownWdsj = int.Parse(textBoxLugdownWdsj.Text);
            equipconfig.TestStandard = comboBoxHJT.Text;
            equipconfig.WorkAutomaticMode = (comboBoxWorkMode.SelectedIndex == 0);
            equipconfig.Tmqxh = comboBoxTMQXH.Text;
            equipconfig.Tmqck = comboBoxTMQCK.Text;
            equipconfig.Tmqckpz = comboBoxTMQPZ.Text;
            equipconfig.isTpTempInstrument = checkBoxTPWSD.Checked;
            equipconfig.CgjNz = comboBoxCgjNz.SelectedIndex;
            equipconfig.CarGdChanel = int.Parse(comboBoxCarGd.Text);
            equipconfig.CGJ10CB_FL = int.Parse(comboBox10CB_FL.Text);
            //equipconfig.isIgbtContainGdyk = checkBoxGdyk.Checked;
            equipconfig.isFqyNhSelfUse = checkBoxIsFqyNhSelfUse.Checked;
            equipconfig.isYdjNhSelfUse = checkBoxIsYdjNhSelfUse.Checked;
            equipconfig.isLljNhSelfUse = checkBoxIsLljNhSelfUse.Checked;
            equipconfig.isYdjUseLinearValue = checkBoxYDJ_UseLinearValue.Checked;
            equipconfig.useWeightWCF = checkBoxUseWeightWCF.Checked;
            equipconfig.WeightWCFaddress = textBoxWeightWCF.Text;
            equipconfig.useJHJK = checkBoxJHJK.Checked;
            equipconfig.useJHSCREEN = checkBoxJH_SCREEN.Checked;
            equipconfig.HideDriverData = checkBoxHideDriverData.Checked;
            equipconfig.JHLBGLB = double.Parse(textBoxJHLBGLYJZ.Text);
            equipconfig.JHLAMBDAMIN = double.Parse(textBoxJHLAMBDAMIN.Text);
            equipconfig.JHLAMBDAMAX = double.Parse(textBoxJHLAMBDAMAX.Text);
            equipconfig.DATASECONDS_TYPE = comboBoxDataSecondsType.Text;
            equipconfig.cd_fqy = checkBoxCD_FQY.Checked;
            equipconfig.cd_ydj = checkBoxCD_YDJ.Checked;
            equipconfig.IsUseNhSjz = checkBoxNHSJZ.Checked;
            equipconfig.NhSjz_Com = comboBoxNHSJZ_COM.Text;
            equipconfig.NhSjz_ComString = comboBoxNHSJZ_COMSTRING.Text;
            equipconfig.BackGroundTestTime = int.Parse(textBoxBackGroundTime.Text);
            equipconfig.CanliHCTestTime = int.Parse(textBoxCanliHCTime.Text);
            equipconfig.JCXLX = comboBoxJcxLx.SelectedIndex;
            equipconfig.CGJR = int.Parse(textBoxCgjR.Text);
            equipconfig.ywBaseValue = double.Parse(textBoxYwBaseValue.Text);
            equipconfig.lambdaXs = int.Parse(comboBoxLambdaxs.Text);
            equipconfig.checkLock = checkBoxCheckLock.Checked;
            equipconfig.OBDJK = checkBoxOBD监控.Checked;
            equipconfig.YdjJzUseK = checkBoxYdjUseK.Checked;
            equipconfig.CarryTantouTime = int.Parse(textBoxCarryTantouTime.Text);
            equipconfig.liftUpAfterStop = checkBoxLiftUpAfterStop.Checked;
            equipconfig.ManualSaveData = checkBoxManualSave.Checked;
            equipconfig.UploadRealTimeData = checkBoxUploadRealTime.Checked;
            equipconfig.isJNDLDisplay = checkBoxJNDL_DISP.Checked;
            equipconfig.isZeroAfterTest = checkBoxZeroAfterTest.Checked;
            equipconfig.CGJ_ServerIP = comboBoxCGJ_ServerIP.Text;
            equipconfig.CGJ_LocalIP = comboBoxCGJ_LocalIP.Text;
            equipconfig.CGJ_ServerPort = int.Parse(comboBoxCGJ_ServerPort.Text);
            equipconfig.CGJ_LocalPort = int.Parse(comboBoxCGJ_LocalPort.Text);
            equipconfig.useOBDYWFirst = checkBoxOBDYW.Checked;
            equipconfig.FxyZeroMode = (Enum_ZeroMode)(comboBoxFqyZeroMode.SelectedIndex);
            equipconfig.NOxFxyZeroMode= (Enum_ZeroMode)(comboBoxNOxFxyZeroMode.SelectedIndex);
            rotateconfig.ZsjIsEnable_ZD = checkBoxZSJ_ZD.Checked;
            rotateconfig.ZsjIsEnable_DY = checkBoxZSJ_DY.Checked;
            rotateconfig.ZsjIsEnable_OBD = checkBoxZSJ_OBD.Checked;
            rotateconfig.ZsjCom_ZD = comboBoxZSJCOM_ZD.Text;
            rotateconfig.ZsjCom_DY = comboBoxZSJCOM_DY.Text;
            rotateconfig.ZsjCom_OBD = comboBoxZSJCOM_OBD.Text;
            rotateconfig.ZsjPz_ZD = comboBoxZSJCOMPZ_ZD.Text;
            rotateconfig.ZsjPz_DY = comboBoxZSJCOMPZ_DY.Text;
            rotateconfig.ZsjPz_OBD = comboBoxZSJCOMPZ_OBD.Text;
            rotateconfig.QyZsjDefault = comboBoxZSJ_QY.Text;
            rotateconfig.CyZsjDefault = comboBoxZSJ_CY.Text;
            rotateconfig.ZsjXh_ZD = comboBoxZSJXH_ZD.Text;
            rotateconfig.ZsjXh_DY = comboBoxZSJXH_DY.Text;
            rotateconfig.ZsjXh_OBD = comboBoxZSJXH_OBD.Text;

            if (!rotateconfig.ZsjIsEnable_ZD && rotateconfig.QyZsjDefault=="振动式")
            {
                MessageBox.Show("汽油转速计选择了振动式，但未配置振动式转速计.", "系统提示");
                return;
            }
            if (!rotateconfig.ZsjIsEnable_DY && rotateconfig.QyZsjDefault == "点烟器")
            {
                MessageBox.Show("汽油转速计选择了点烟器，但未配置点烟器转速计.", "系统提示");
                return;
            }
            if (!rotateconfig.ZsjIsEnable_OBD && rotateconfig.QyZsjDefault == "OBD")
            {
                MessageBox.Show("汽油转速计选择了OBD，但未配置OBD转速计.", "系统提示");
                return;
            }
            if (!rotateconfig.ZsjIsEnable_ZD && rotateconfig.CyZsjDefault == "振动式")
            {
                MessageBox.Show("柴油转速计选择了振动式，但未配置振动式转速计.", "系统提示");
                return;
            }
            if (!rotateconfig.ZsjIsEnable_DY && rotateconfig.CyZsjDefault == "点烟器")
            {
                MessageBox.Show("柴油转速计选择了点烟器，但未配置点烟器转速计.", "系统提示");
                return;
            }
            if (!rotateconfig.ZsjIsEnable_OBD && rotateconfig.CyZsjDefault == "OBD")
            {
                MessageBox.Show("柴油转速计选择了OBD，但未配置OBD转速计.", "系统提示");
                return;
            }
            configini.writeRotateConfig(rotateconfig);
            

            if (configini.writeEquipmentConfig(equipconfig))
                MessageBox.Show("保存成功.", "系统提示");
            else
                MessageBox.Show("数据输入有误,请检查.", "未成功保存");
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            carinfor.DynConfigInfdata btgconfig = configini.getDynConfigIni();
            try
            {
                btgconfig.Zsj = comboBoxDynZsj.Text;
                btgconfig.Zsjck = comboBoxDynZsjCk.Text;
                btgconfig.cczs = int.Parse(textBoxDynZs.Text);
                btgconfig.stableTime = int.Parse(textBoxDynZsTime.Text);
                btgconfig.forceTime = int.Parse(textBoxDynForceTime.Text);
                btgconfig.FuelforceTime = int.Parse(textBoxFuelForceTime.Text);
                btgconfig.FuelSdQj = float.Parse(textBoxFuelSdQj.Text);
                btgconfig.DynSdqj = float.Parse(textBoxDynSdqj.Text);
                btgconfig.DynVwSdqj= float.Parse(textBoxDynVwSdqj.Text);
                btgconfig.FuelForceQj = float.Parse(textBoxFuelForceQj.Text);
                btgconfig.DynForceQj = float.Parse(textBoxDynForceQj.Text);
                btgconfig.DynYkStyle = radioButtonDynZdyk.Checked ? 0 : 1;
                btgconfig.DynWjyktd = int.Parse(comboBoxDynYkTd.Text);
                btgconfig.DynReStartStyle = radioButtonDynReStartFrom60.Checked ? 0 : 1;
                btgconfig.DynUseGddw = checkBoxDynGddw.Checked;
                btgconfig.DynGddwTime = int.Parse(textBoxDynGddwTime.Text);
                btgconfig.DynMaxWaitTime = int.Parse(textBoxDynMaxWaitTime.Text);
                btgconfig.DynFuelJk = checkBoxDynJkYh.Checked;
                btgconfig.DynFuelXz = double.Parse(textBoxDynYhxz.Text);
                btgconfig.DynUseYkdw = checkBoxDynYkdw.Checked;
                btgconfig.FuelTestFjjs = int.Parse(textBoxFuelTestFjcs.Text);
                btgconfig.DynYkKey = textBoxDynYkKey.Text;
                btgconfig.DynFileStyle = radioButtonDynFileJson.Checked?0:1;
                btgconfig.DynStopUnstable = checkBoxDynStopUnstable.Checked;
                btgconfig.DynUnstableTime = int.Parse(textBoxDynUnstableTime.Text);
                btgconfig.DynTl = checkBoxDYNTL.Checked;
                btgconfig.DynBackTest = checkBoxDynBackTest.Checked;
                btgconfig.DynCO2Test = checkBoxDynCO2Test.Checked;
                btgconfig.DynFlowBack = checkBoxDynFlowBack.Checked;
                btgconfig.DynYkqr = checkBoxDynYkqr.Checked;
                btgconfig.DynUseManualKey = checkBoxDynManulKey.Checked;
                if (configini.writeDynConfigIni(btgconfig))
                    MessageBox.Show("保存成功.", "系统提示");
                else
                    MessageBox.Show("数据输入有误,请检查.", "未成功保存");
            }
            catch
            {
                MessageBox.Show("数据输入有误,请检查.", "未成功保存");
            }
        }

        private void comboBoxDynZsj_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBoxDynZsj.Text != "废气仪" && comboBoxDynZsj.Text != "烟度计")
            {
                comboBoxDynZsjCk.Enabled = true;
            }
            else
            {
                comboBoxDynZsjCk.Enabled = false;
            }
        }
        selfCheckIni selfcheckini = new selfCheckIni();
        selfcheckInfdata selfcheckinfdata = new selfcheckInfdata();
        fqyconfigIni fqyconfigini = new fqyconfigIni();
        fqyconfigInfdata fqyconfigdata = new fqyconfigInfdata();
        fqyconfigInfdata NOfxyconfigdata = new fqyconfigInfdata();
        ydjconfigInfdata ydjconfigdata = new ydjconfigInfdata();
        private void initSelfData()
        {
            selfcheckinfdata = fqyconfigini.getSelfcheckConfigIni();
            fqyconfigdata = fqyconfigini.getfqyConfigIni();
            NOfxyconfigdata = fqyconfigini.getNOfxyConfigIni();
            ydjconfigdata = fqyconfigini.getYDJConfigIni();
            textBoxfxy_O2_0.Text = fqyconfigdata.O2_zero.ToString("0.00");
            textBoxfxy_CO_1.Text = fqyconfigdata.Co_low.ToString("0.00");
            textBoxfxy_CO2_1.Text = fqyconfigdata.Co2_low.ToString("0.00");
            textBoxfxy_HC_1.Text = fqyconfigdata.Hc_low.ToString("0.00");
            textBoxfxy_NO_1.Text = fqyconfigdata.No_low.ToString("0.00");
            textBoxfxy_NO2_1.Text = fqyconfigdata.No2_low.ToString("0.00");
            textBoxfxy_CO_2.Text = fqyconfigdata.Co_midlow.ToString("0.00");
            textBoxfxy_CO2_2.Text = fqyconfigdata.Co2_midlow.ToString("0.00");
            textBoxfxy_HC_2.Text = fqyconfigdata.Hc_midlow.ToString("0.00");
            textBoxfxy_NO_2.Text = fqyconfigdata.No_midlow.ToString("0.00");
            textBoxfxy_NO2_2.Text = fqyconfigdata.No2_midlow.ToString("0.00");
            textBoxfxy_CO_3.Text = fqyconfigdata.Co_midhigh.ToString("0.00");
            textBoxfxy_CO2_3.Text = fqyconfigdata.Co2_midhigh.ToString("0.00");
            textBoxfxy_HC_3.Text = fqyconfigdata.Hc_midhigh.ToString("0.00");
            textBoxfxy_NO_3.Text = fqyconfigdata.No_midhigh.ToString("0.00");
            textBoxfxy_NO2_3.Text = fqyconfigdata.No2_midhigh.ToString("0.00");
            textBoxfxy_CO_4.Text = fqyconfigdata.Co_high.ToString("0.00");
            textBoxfxy_CO2_4.Text = fqyconfigdata.Co2_high.ToString("0.00");
            textBoxfxy_HC_4.Text = fqyconfigdata.Hc_high.ToString("0.00");
            textBoxfxy_NO_4.Text = fqyconfigdata.No_high.ToString("0.00");
            textBoxfxy_NO2_4.Text = fqyconfigdata.No2_high.ToString("0.00");
            checkBoxIsCheckFqyNO2.Checked = fqyconfigdata.IsCheckNO2;

            textBoxFQY_BQNO_ZERO.Text=fqyconfigdata.BqNO_zero ;
            textBoxFQY_BQNO_LOW.Text=fqyconfigdata.BqNO_low ;
            textBoxFQY_BQNO_MIDLOW.Text=fqyconfigdata.BqNO_midlow ;
            textBoxFQY_BQNO_MIDHIGH.Text=fqyconfigdata.BqNO_midhigh ;
            textBoxFQY_BQNO_HIGH.Text=fqyconfigdata.BqNO_high;
            textBoxFQY_NO2NO_ZERO.Text = fqyconfigdata.NO2NO_zero;
            textBoxFQY_NO2NO_LOW.Text = fqyconfigdata.NO2NO_low;
            textBoxFQY_NO2NO_MLOW.Text = fqyconfigdata.NO2NO_midlow;
            textBoxFQY_NO2NO_MHIGH.Text = fqyconfigdata.NO2NO_midhigh;
            textBoxFQY_NO2NO_HIGH.Text = fqyconfigdata.NO2NO_high;

            textBoxNOx_CO2_1.Text = NOfxyconfigdata.Co2_low.ToString("0.00");
            textBoxNOx_NO_1.Text = NOfxyconfigdata.No_low.ToString("0.00");
            textBoxNOx_NO2_1.Text = NOfxyconfigdata.No2_low.ToString("0.00");
            textBoxNOx_CO2_2.Text = NOfxyconfigdata.Co2_midlow.ToString("0.00");
            textBoxNOx_NO_2.Text = NOfxyconfigdata.No_midlow.ToString("0.00");
            textBoxNOx_NO2_2.Text = NOfxyconfigdata.No2_midlow.ToString("0.00");
            textBoxNOx_CO2_3.Text = NOfxyconfigdata.Co2_midhigh.ToString("0.00");
            textBoxNOx_NO_3.Text = NOfxyconfigdata.No_midhigh.ToString("0.00");
            textBoxNOx_NO2_3.Text = NOfxyconfigdata.No2_midhigh.ToString("0.00");
            textBoxNOx_CO2_4.Text = NOfxyconfigdata.Co2_high.ToString("0.00");
            textBoxNOx_NO_4.Text = NOfxyconfigdata.No_high.ToString("0.00");
            textBoxNOx_NO2_4.Text = NOfxyconfigdata.No2_high.ToString("0.00");
            checkBoxIsSelfCheckNO2.Checked = NOfxyconfigdata.IsCheckNO2;

            textBoxNOX_BQNO_ZERO.Text = NOfxyconfigdata.BqNO_zero;
            textBoxNOX_BQNO_LOW.Text = NOfxyconfigdata.BqNO_low;
            textBoxNOX_BQNO_MIDLOW.Text = NOfxyconfigdata.BqNO_midlow;
            textBoxNOX_BQNO_MIDHIGH.Text = NOfxyconfigdata.BqNO_midhigh;
            textBoxNOX_BQNO_HIGH.Text = NOfxyconfigdata.BqNO_high;
            textBoxNOX_NO2NO_ZERO.Text = NOfxyconfigdata.NO2NO_zero;
            textBoxNOX_NO2NO_LOW.Text = NOfxyconfigdata.NO2NO_low;
            textBoxNOX_NO2NO_MLOW.Text = NOfxyconfigdata.NO2NO_midlow;
            textBoxNOX_NO2NO_MHIGH.Text = NOfxyconfigdata.NO2NO_midhigh;
            textBoxNOX_NO2NO_HIGH.Text = NOfxyconfigdata.NO2NO_high;

            textBoxJzhxGl.Text = selfcheckinfdata.IHP.ToString("0.0");
            textBoxSet_llj_myll.Text = selfcheckinfdata.LLJMYLL.ToString("0.0");
            comboBoxJzhxWc.Text = selfcheckinfdata.jchxwc.ToString("0.0");

            textBoxPEF.Text = fqyconfigdata.PEF.ToString("0.000");

            textBoxSet_ydj_check30bz.Text = ydjconfigdata.bz_30.ToString("0.00");// = float.Parse(textBoxSet_ydj_checklowbz.Text);
            textBoxSet_ydj_check50bz.Text=ydjconfigdata.bz_50.ToString("0.00");// = float.Parse(textBoxSet_ydj_checkhighbz.Text);
            textBoxSet_ydj_check70bz.Text = ydjconfigdata.bz_70.ToString("0.00");
            textBoxSet_ydj_check90bz.Text = ydjconfigdata.bz_90.ToString("0.00");
            textBoxSet_ydj_check100bz.Text = ydjconfigdata.bz_100.ToString("0.00");
            textBoxYDJ_N0_NO.Text = ydjconfigdata.Ydj_No_0;
            textBoxYDJ_N30_NO.Text = ydjconfigdata.Ydj_No_30;
            textBoxYDJ_N50_NO.Text = ydjconfigdata.Ydj_No_50;
            textBoxYDJ_N70_NO.Text = ydjconfigdata.Ydj_No_70;
            textBoxYDJ_N90_NO.Text = ydjconfigdata.Ydj_No_90;
            textBoxYDJ_N100_NO.Text = ydjconfigdata.Ydj_No_100;
        }
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                selfcheckinfdata.IHP = float.Parse(textBoxJzhxGl.Text);
                selfcheckinfdata.jchxwc = double.Parse(comboBoxJzhxWc.Text);
                selfcheckinfdata.LLJMYLL = float.Parse(textBoxSet_llj_myll.Text);

                fqyconfigdata.Co_high = float.Parse(textBoxfxy_CO_4.Text);
                fqyconfigdata.Co2_high = float.Parse(textBoxfxy_CO2_4.Text);
                fqyconfigdata.Hc_high = float.Parse(textBoxfxy_HC_4.Text);
                fqyconfigdata.No_high = float.Parse(textBoxfxy_NO_4.Text);
                fqyconfigdata.No2_high = float.Parse(textBoxfxy_NO2_4.Text);
                fqyconfigdata.O2_high = 0;
                fqyconfigdata.Co_midhigh = float.Parse(textBoxfxy_CO_3.Text);
                fqyconfigdata.Co2_midhigh = float.Parse(textBoxfxy_CO2_3.Text);
                fqyconfigdata.Hc_midhigh = float.Parse(textBoxfxy_HC_3.Text);
                fqyconfigdata.No_midhigh = float.Parse(textBoxfxy_NO_3.Text);
                fqyconfigdata.No2_midhigh = float.Parse(textBoxfxy_NO2_3.Text);

                fqyconfigdata.Co_midlow = float.Parse(textBoxfxy_CO_2.Text);
                fqyconfigdata.Co2_midlow = float.Parse(textBoxfxy_CO2_2.Text);
                fqyconfigdata.Hc_midlow = float.Parse(textBoxfxy_HC_2.Text);
                fqyconfigdata.No_midlow = float.Parse(textBoxfxy_NO_2.Text);
                fqyconfigdata.No2_midlow = float.Parse(textBoxfxy_NO2_2.Text);
                fqyconfigdata.Co_low = float.Parse(textBoxfxy_CO_1.Text);
                fqyconfigdata.Co2_low = float.Parse(textBoxfxy_CO2_1.Text);
                fqyconfigdata.Hc_low = float.Parse(textBoxfxy_HC_1.Text);
                fqyconfigdata.No_low = float.Parse(textBoxfxy_NO_1.Text);
                fqyconfigdata.No2_low = float.Parse(textBoxfxy_NO2_1.Text);
                fqyconfigdata.O2_low = 0;
                fqyconfigdata.Co_zero = float.Parse(textBoxfxy_CO_0.Text);
                fqyconfigdata.Co2_zero = float.Parse(textBoxfxy_CO2_0.Text);
                fqyconfigdata.Hc_zero = float.Parse(textBoxfxy_HC_0.Text);
                fqyconfigdata.No_zero = float.Parse(textBoxfxy_NO_0.Text);
                fqyconfigdata.No2_zero = float.Parse(textBoxfxy_NO2_0.Text);
                fqyconfigdata.O2_zero = float.Parse(textBoxfxy_O2_0.Text);

                fqyconfigdata.PEF = float.Parse(textBoxPEF.Text);
                fqyconfigdata.IsCheckNO2 = checkBoxIsCheckFqyNO2.Checked;

                fqyconfigdata.BqNO_zero = textBoxFQY_BQNO_ZERO.Text;
                fqyconfigdata.BqNO_low = textBoxFQY_BQNO_LOW.Text;
                fqyconfigdata.BqNO_midlow = textBoxFQY_BQNO_MIDLOW.Text;
                fqyconfigdata.BqNO_midhigh = textBoxFQY_BQNO_MIDHIGH.Text;
                fqyconfigdata.BqNO_high = textBoxFQY_BQNO_HIGH.Text;
                fqyconfigdata.NO2NO_zero = textBoxFQY_NO2NO_ZERO.Text;
                fqyconfigdata.NO2NO_low = textBoxFQY_NO2NO_LOW.Text;
                fqyconfigdata.NO2NO_midlow = textBoxFQY_NO2NO_MLOW.Text;
                fqyconfigdata.NO2NO_midhigh = textBoxFQY_NO2NO_MHIGH.Text;
                fqyconfigdata.NO2NO_high = textBoxFQY_NO2NO_HIGH.Text;

                NOfxyconfigdata.Co2_zero = 0;
                NOfxyconfigdata.No_zero = 0;
                NOfxyconfigdata.No2_zero = 0;
                NOfxyconfigdata.Co2_low = float.Parse(textBoxNOx_CO2_1.Text);
                NOfxyconfigdata.No_low = float.Parse(textBoxNOx_NO_1.Text);
                NOfxyconfigdata.No2_low = float.Parse(textBoxNOx_NO2_1.Text);
                NOfxyconfigdata.Co2_midlow = float.Parse(textBoxNOx_CO2_2.Text);
                NOfxyconfigdata.No_midlow = float.Parse(textBoxNOx_NO_2.Text);
                NOfxyconfigdata.No2_midlow = float.Parse(textBoxNOx_NO2_2.Text);
                NOfxyconfigdata.Co2_midhigh = float.Parse(textBoxNOx_CO2_3.Text);
                NOfxyconfigdata.No_midhigh = float.Parse(textBoxNOx_NO_3.Text);
                NOfxyconfigdata.No2_midhigh = float.Parse(textBoxNOx_NO2_3.Text);
                NOfxyconfigdata.Co2_high = float.Parse(textBoxNOx_CO2_4.Text);
                NOfxyconfigdata.No_high = float.Parse(textBoxNOx_NO_4.Text);
                NOfxyconfigdata.No2_high = float.Parse(textBoxNOx_NO2_4.Text);
                NOfxyconfigdata.IsCheckNO2 = checkBoxIsSelfCheckNO2.Checked;


                NOfxyconfigdata.BqNO_zero = textBoxNOX_BQNO_ZERO.Text;
                NOfxyconfigdata.BqNO_low = textBoxNOX_BQNO_LOW.Text;
                NOfxyconfigdata.BqNO_midlow = textBoxNOX_BQNO_MIDLOW.Text;
                NOfxyconfigdata.BqNO_midhigh = textBoxNOX_BQNO_MIDHIGH.Text;
                NOfxyconfigdata.BqNO_high = textBoxNOX_BQNO_HIGH.Text;

                NOfxyconfigdata.NO2NO_zero = textBoxNOX_NO2NO_ZERO.Text;
                NOfxyconfigdata.NO2NO_low = textBoxNOX_NO2NO_LOW.Text;
                NOfxyconfigdata.NO2NO_midlow = textBoxNOX_NO2NO_MLOW.Text;
                NOfxyconfigdata.NO2NO_midhigh = textBoxNOX_NO2NO_MHIGH.Text;
                NOfxyconfigdata.NO2NO_high = textBoxNOX_NO2NO_HIGH.Text;

                ydjconfigdata.bz_30 = float.Parse(textBoxSet_ydj_check30bz.Text);
                ydjconfigdata.bz_50 = float.Parse(textBoxSet_ydj_check50bz.Text);
                ydjconfigdata.bz_70 = float.Parse(textBoxSet_ydj_check70bz.Text);
                ydjconfigdata.bz_90 = float.Parse(textBoxSet_ydj_check90bz.Text);
                ydjconfigdata.bz_100 = float.Parse(textBoxSet_ydj_check100bz.Text);

                ydjconfigdata.Ydj_No_0 = textBoxYDJ_N0_NO.Text;
                ydjconfigdata.Ydj_No_30 = textBoxYDJ_N30_NO.Text;
                ydjconfigdata.Ydj_No_50 = textBoxYDJ_N50_NO.Text;
                ydjconfigdata.Ydj_No_70 = textBoxYDJ_N70_NO.Text;
                ydjconfigdata.Ydj_No_90 = textBoxYDJ_N90_NO.Text;
                ydjconfigdata.Ydj_No_100 = textBoxYDJ_N100_NO.Text;

                fqyconfigini.writeSelfcheckconfigInfdata(selfcheckinfdata);
                fqyconfigini.writefqyconfigInfdata(fqyconfigdata);
                fqyconfigini.writeNOfxyconfigInfdata(NOfxyconfigdata);
                fqyconfigini.writeYDJconfigInfdata(ydjconfigdata);          
                MessageBox.Show("保存成功", "提示");

            }
            catch
            {
                MessageBox.Show("保存失败，输入格式有误", "提示");
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                string rXml = string.Empty;
                HttpWebRequest myHttpWebRequest = System.Net.WebRequest.Create(updateUrl) as HttpWebRequest;
                myHttpWebRequest.KeepAlive = false;
                myHttpWebRequest.AllowAutoRedirect = false;
                myHttpWebRequest.UserAgent = "Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)";
                myHttpWebRequest.Timeout = 5000;
                myHttpWebRequest.ContentType = "application/x-www-form-urlencoded;charset=utf-8";
                using (HttpWebResponse res = (HttpWebResponse)myHttpWebRequest.GetResponse())
                {
                    if (res.StatusCode == HttpStatusCode.OK || res.StatusCode == HttpStatusCode.PartialContent)//返回为200或206
                    {
                        string dd = res.ContentEncoding;
                        System.IO.Stream strem = res.GetResponseStream();
                        System.IO.StreamReader r = new System.IO.StreamReader(strem);
                        rXml = r.ReadToEnd();
                    }
                    else
                    {
                        MessageBox.Show("无法连接到远程服务器");
                        return;
                    }
                }
                updateInf updateinf = JsonConvert.DeserializeObject<updateInf>(rXml);
                if (string.Compare(updateinf.latestversion, version) > 0)
                {
                    if (MessageBox.Show("有新版本：" + updateinf.latestversion + "\r\n" + "更新内容：" + updateinf.changelog + "\r\n是否进行更新?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                    {
                        return;
                    }
                    var mainFile = Application.StartupPath + @"\update.exe";
                    Process p = new Process();
                    p.StartInfo.UseShellExecute = false;
                    p.StartInfo.RedirectStandardOutput = true;
                    p.StartInfo.FileName = mainFile;
                    p.StartInfo.CreateNoWindow = true;
                    p.StartInfo.Arguments = updateinf.downloadurl + " " + "系统设置.exe";
                    p.Start();
                    System.Environment.Exit(0);
                }
                else
                {
                    MessageBox.Show("没有更新版本了！");
                }

            }
            catch (Exception er)
            {
                MessageBox.Show("检查更新出现错误:" + er.Message);
            }
        }
    }
}
